package com.crazyauntzhang.easyshopbackend.config;

import com.crazyauntzhang.easyshopbackend.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置：配置拦截与不拦截的请求路径
 */
@Configuration
public class LoginInterceptorConfiguration implements WebMvcConfigurer {

	private final LoginInterceptor loginInterceptor;

	@Autowired
	public LoginInterceptorConfiguration(LoginInterceptor loginInterceptor) {
		this.loginInterceptor = loginInterceptor;
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(loginInterceptor)
				.addPathPatterns("/**")
				.excludePathPatterns("/login");
	}
}
